/**
 * Author:yuiop
 * Date:2022/6/22 11:10
 */
package com.devops.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devops.admin.mapper.DOSProjectVersionPhaseRelationMapper;
import com.devops.admin.model.DOSProjectVersion;
import com.devops.admin.model.DOSProjectVersionPhaseRelation;
import com.devops.admin.service.DOSProjectVersionPhaseRelationService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DOSProjectVersionPhaseRelationServiceImpl extends ServiceImpl<DOSProjectVersionPhaseRelationMapper, DOSProjectVersionPhaseRelation> implements DOSProjectVersionPhaseRelationService {
    //条件获取DOSProjectVersionPhaseRelation集合
    @Override
    public List<DOSProjectVersionPhaseRelation> getByCondition(DOSProjectVersionPhaseRelation condition) {
        LambdaQueryWrapper<DOSProjectVersionPhaseRelation> queryWrapper = new LambdaQueryWrapper<>();
        if (condition.getVersionId() != null) {
            queryWrapper.eq(DOSProjectVersionPhaseRelation::getVersionId,condition.getVersionId());
        }

        if (condition.getPhaseType() != null) {
            queryWrapper.eq(DOSProjectVersionPhaseRelation::getPhaseType,condition.getPhaseType());
        }

        if (condition.getPhaseStatusType() != null) {
            queryWrapper.eq(DOSProjectVersionPhaseRelation::getPhaseStatusType,condition.getPhaseStatusType());
        }

        if (condition.getCurrentFlag() != null) {
            queryWrapper.eq(DOSProjectVersionPhaseRelation::getCurrentFlag,condition.getCurrentFlag());
        }

        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 获取发版超时的projectVersion 超过1小时
     * @return
     */
    @Override
    public DOSProjectVersion getTimeoutProjectVersion(Integer projectVersionId) {
        return baseMapper.getTimeoutProjectVersion(projectVersionId);
    }
}
